import 'package:find_friend/const/const.dart';
import 'package:flutter/material.dart';

class MineTagWidget extends StatelessWidget {

  final List<String> label;

  const MineTagWidget({Key key, this.label}) : super(key: key);

  Widget _createTag(String text) {
      return Container(
        height: 24,
        width: text.length * 15.0 + 10,
        padding: const EdgeInsets.only(bottom: 2),
        alignment: Alignment.center,
        // padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
        decoration: BoxDecoration(
          image: DecorationImage(image: AssetImage("assets/my-biaoqian${text.length}.png"),fit: BoxFit.fill)
        ),
        child: Text(text, style: instanceTextStyle(11, Colors.white),),
      );
    }

  Widget _createTagsList() {
    if(label != null){
      int len = label.length > 3 ? 3 : label.length;
      List<String> temp = label.sublist(0, len);

      return Row(
              children: temp.map((e) => _createTag(e)).toList(),
            );
    } else {
      return _createTag("个性标签");
    }
  }

  @override
  Widget build(BuildContext context) {
    return _createTagsList();
  }
}